﻿using Model;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TodoListController : MonoBehaviour {

    public TodoList mTodoList;
    public Button Creationbutton;

    public Transform obj_Parent;

    public Text TodoItemtext;

    // Use this for initialization
    void Start () {
        mTodoList = new TodoList();
        Creationbutton = transform.Find("AddTodoListButton").GetComponent<Button>();
        obj_Parent = transform.Find("TodoListContent");
        Creationbutton.onClick.AddListener(CreationTodoListClick);
    }
	
	// Update is called once per frame
	void Update () {
		
	}

    public void CreationTodoListClick()
    {
        TodoItem todoItem = new TodoItem ("标题"+ mTodoList.todoList.Count, false);

     
        Text temp = Instantiate(TodoItemtext, obj_Parent);

        temp.text = todoItem.Headline;
        mTodoList.AddTodoItem(todoItem);
        Debug.Log(mTodoList.todoList.Count);
    }
}
